<template>
	<view>
		<view class="btgourd" v-if="user_flage">
			<view >
				<button class="new_login text" plain="true" open-type="getUserInfo" @getuserinfo="weixin()">授权登录</button>
				<text class="text">您登录后可下载文献</text>
			</view>
		</view>
		<view v-if="!user_flage" class="btgourd1">
			<view class="me_img1">
				<view style="display: flex;">
					<image class="image" :src="userimg"></image>
					<view style="display: flex; flex-direction: column;justify-content: space-around;">
						<view style="color: white;margin-left: 40rpx;">{{name}}  {{gender}}</view>
						<view style="color: white;margin-left: 40rpx;">ID:wxa0c55c8a76459f0</view>
						
					</view>
					<view>
						
					</view>
				</view>
				
			</view>
		</view>

		<view class="list_all" >
			<view class="list1">
				<view class="after">
					<view class="icon iconfont icon-ai-phone bigsize" style="color: #23a0d5;"></view>
					<view class="size" style="margin-left: 30rpx;">{{[phone]}}</view>
				</view>
			</view>
		</view>

		<view class="list_all" @click="orde">
			<view class="list1">
				<view class="after">
					<view class="icon iconfont icon-jilu bigsize" style="color: #efea4f;"></view>
					<view class="size" style="margin-left: 30rpx;">文献资料</view>
				</view>
			</view>
		</view>


		<view class="list_all">
			<view class="list1">
				<view class="after">
					<view class="icon iconfont icon-kefu bigsize" style="color: #f9000c;"></view>
					<view style="margin-left: -585rpx;"><button class="new_login1 size" style="color: #000000;" plain="true" open-type='contact'
						 session-from=''>小程序客服</button></view>
				</view>
			</view>
		</view>

<view class="list_all" @click="yichang">
			<view class="list1">
				<view class="after">
					<view class="icon iconfont icon-location bigsize" style="color: #43f349;"></view>
					<view class="size" style="margin-left: 30rpx;">定位异常教程</view>
				</view> 
			</view>
		</view>

		<view class="list_all" @click="username">
			<view class="list1">
				<view class="after">
					<view class="icon iconfont icon-weibiaoti-_huabanfuben bigsize" style="color: #23cbd3;"></view>
					<view class="size" style="margin-left: 30rpx;">关于小程序</view>
				</view>
			</view>
		</view>
		<view class="list_all" v-if="!user_flage" @click="cls">
			<view class="list1">
				<view class="after">
					<view class="icon iconfont icon-baidu bigsize" style="color: #c3c6d3;"></view>
					<view class="size" style="margin-left: 30rpx;">退出账号</view>
				</view>
			</view>
		</view>
		</view>
		
	</view>

</template>

<script>
	export default {
		data() {
			return {
				user_flage: true,
				userimg: '',
				name: '',
				gender: '',
				show: false,
				loading: false,
				aaa: false,
				phone:''
			}
		},

		onShareAppMessage: function(e) {
			return {
				title: 'Q键打卡小程序',
				path: 'pages/index/index',
			}
		},
		onShareTimeline: function(e) {
			return {
				title: 'Q键打卡小程序',
				path: 'pages/index/index',
			}
		},
		methods: {
			
			weixin() {
				uni.getUserInfo({
					success: (res) => {
						let username = JSON.parse(res.rawData)
						uni.setStorage({
							key: 'xiaochengxu',
							data: username,
							success: function() {
								var pages = getCurrentPages();
								var curPage = pages[pages.length - 1];
								curPage.onLoad();
							}
						});
					}
				})
			},
			// 退出
			cls() {
				uni.removeStorage({
					key: "xiaochengxu",
					success: () => {
						uni.showToast({
							title: '退出成功',
							duration: 2000,
							icon: 'none',
							success() {
								var pagesss = getCurrentPages();
								var curPage = pagesss[pagesss.length - 1];
								curPage.onLoad();
							}
						});
					}
				})
			},
			// // go_baidu
			// go_baidu() {
			// 	uni.navigateTo({
			// 		url: "../webview/webview"
			// 	})
			// },
			// orde
			orde() {
				uni.getStorage({
					key: "xiaochengxu",
					success: res => {
						uni.navigateTo({
							url: "../../page_a/learn/learn"
						})
					},
					fail: () => {
						uni.showToast({
							title: '请先登录',
							icon: "none",
							duration: 2000
						});
					}
				})
				
			},
			yichang()
			{
					uni.navigateTo({
						url: "../../page_a/yichang/yichang",
						fail: (e) => {
							console.log(e)
						}
					})
				},
			// 用户协议
			username() {
				uni.navigateTo({
					url: "../../page_a/aboutme/aboutme",
					fail: (e) => {
						console.log(e)
					}
				})
			}
		},
		onLoad(option) {
			uni.getStorage({
				key: "xiaochengxu",
				success: res => {
					this.user_flage = false
					let arrys = res.data
					this.name = arrys.nickName
					this.userimg = arrys.avatarUrl
					// 处理性别
					if (arrys.gender == 1) {
						this.gender = '男'
					} else if (arrys.gender == 0) {
						this.gender = "女"
					} else {
						this.gender = "还未填写"
					}
				},
				fail: () => {
					this.user_flage = true
				}
			})
			uni.getSystemInfo({
				success: (res) => {
					this.phone=res.model
					
				}
			})
		},
		components: {}
	}
</script>

<style scoped lang="less">
	.size {
		font-size: 35rpx;
	}

	.bigsize {
		font-size: 40rpx;
	}

	/* 退出 */
	.cls {
		width: 120rpx;
		height: 60rpx;
		/* color: white; */
		font-size: 25rpx;
		line-height: 60rpx;
		border-radius: 4rpx;
		text-align: center;
		border: 0;
		background-color: #ffef08;
	}

	.btgourd {
		width: 94%;
		height: 300rpx;
		margin: 0% auto;
		border-radius: 25rpx; 
		background-color: #00B1FE;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.btgourd1 {
		width: 94%;
		height: 300rpx;
		margin: 0% auto;
		border-radius: 25rpx; 
		display: flex;
		align-items: center;
		background-color: #fe5490;

	}

	.me_img1 {
		display: flex;
		width: 86%;
		margin: 0 auto;
		justify-content: space-between;
		align-items: center;
	}

	.new_login {
		width: 250rpx;
		height: 100rpx;
		/* color: white; */
		font-size: 42rpx;
		line-height: 100rpx;
		border-radius: 10rpx;
		text-align: center;
		border: 0;
		margin-bottom: 10%;
		border-bottom: 2rpx solid #FFFFFF;
	}

	.new_login1 {
		width: 1400rpx;
		height: 120rpx;
		padding: 0;
		margin: 0;
		border: 0;
		padding-top: 20rpx;
		font-size: 35rpx;
	}

	.text {
		color: white;
		font-weight: bolder;
		letter-spacing: 2rpx;
	}

	.image {
		width: 155rpx;
		height: 155rpx;
		border-radius: 20%;
	}

	/* less */
	.list_all {
		width: 94%;
		height: 60px;
		line-height: 60px;
		// background-color: red;
		margin: 0 auto;
		border-bottom: 2rpx solid #D9D9D9;

		.list1 {
			.after {
				display: flex;
			}
		}
	}
	//卡片
	.bottom_box{
		width: 100%;
		height: 105rpx;
		position: absolute;
		bottom: 1%;
		left: 0;
	}
	.bottom{
		width: 94%;
		height: 105rpx;
		margin: 0 auto;
		text-align: center;
		line-height: 100rpx;
		font-size: 38rpx;
		letter-spacing: 4rpx;
		background-color: #DFDFE6;
		border-radius: 15rpx;
		}
</style>
